#include "dlm.h"
#include "stdio.h"


/* 终端输入 ->
	{ "mod": "libdl3.so", "fx": "roman_number", "argv": null }
	{ "mod": "libdl2.so", "fx": "numerial_calculate", "argv": {"a": 7, "b": 31} }
 */

#ifdef OS_Linux
char* fx_cb1 = "{ \"mod\": \"libdl2.so\", \"fx\": \"numerial_calculate\", \"argv\": {\"a\": 7, \"b\": 31} }";
char* fx_cb2 = "{ \"mod\": \"libdl3.so\", \"fx\": \"roman_number\", \"argv\": null }";
#endif
#ifdef OS_Cygwin
char* fx_cb1 = "{ \"mod\": \"cygdl2.dll\", \"fx\": \"numerial_calculate\", \"argv\": {\"a\": 7, \"b\": 31} }";
char* fx_cb2 = "{ \"mod\": \"cygdl3.dll\", \"fx\": \"roman_number\", \"argv\": null }";
#endif

struct  __dynamic_function_pool FxPool;

int main(int argc, char* argv[])
{
	fx_pool_construct(&FxPool);
	// 加载多个动态扩展模块，不用中断主线程，也不用重新编译服务程序
#ifdef OS_Linux
	load_dynamic_module("libdl2.so", &FxPool);
	load_dynamic_module("libdl3.so", &FxPool);
#endif
#ifdef OS_Cygwin
	load_dynamic_module("cygdl2.dll", &FxPool);
	load_dynamic_module("cygdl3.dll", &FxPool);
#endif

	fx_pool_list(&FxPool);

	char fx_retval[1024];
	FX_TRIGGER(fx_cb1, fx_retval, &FxPool); printf("%s\n", fx_retval);
	
	FX_TRIGGER(fx_cb2, fx_retval, &FxPool); 
	
	fx_pool_release(&FxPool);
}